package com.server.questionbank.snframe.mapper.Course.Type;

import com.server.questionbank.snframe.domain.Course.Type.CourseLabel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CourseLabelMapper {
    // 根据类型ID列表查询课程标签
    @Select("<script>" +
            "SELECT " +
            "course_label.label_id, course_label.label_name, course_label.label_desc, course_label.create_date " +
            "FROM course_label " +
            "JOIN course_label_type_mapping ON course_label.label_id = course_label_type_mapping.label_id " +
            "JOIN course_type ON course_type.type_id = course_label_type_mapping.type_id " +
            "WHERE 1=1 " +
            "<if test='typeIdList != null and typeIdList.size() > 0'> AND " +
            "<foreach collection='typeIdList' item='typeId' open='(' separator='OR' close=')'>" +
            "course_type.type_id = #{typeId}" +
            "</foreach>" +
            "</if>" +
            "</script>")
    public List<CourseLabel> getCourseLabelByTypeIdList(@Param("typeIdList") List<Long> typeIdList);

    // 根据课程ID查询课程标签
    @Select("SELECT * FROM course_label, course_label_mapping " +
            "WHERE course_label.label_id = course_label_mapping.label_id " +
            "AND course_label_mapping.course_id = #{courseId};")
    public List<CourseLabel> getCourseLabelByClassId(@Param("courseId") Long courseId);

}




